﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class View_Vouchers : _View_Vouchers
    {
        public static View_Vouchers GetByIds(string ids)
        {
            View_Vouchers vc = new View_Vouchers();
            vc.Where.ID.Value = ids;
            vc.Where.ID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.In;
            vc.Query.Load();

            return vc;
        }

        public static View_Vouchers GetBySerieId(Guid id)
        {
            View_Vouchers vc = new View_Vouchers();
            vc.Where.SerieID.Value = id;
            vc.Query.Load();

            return vc;
        }

        public static View_Vouchers GetByCode(string code)
        {
            View_Vouchers vc = new View_Vouchers();
            vc.Where.Code.Value = code;
            vc.Query.Load();

            return vc;
        }

        public static View_Vouchers GetById(Guid id)
        {
            View_Vouchers vc = new View_Vouchers();
            vc.Where.ID.Value = id;
            vc.Query.Load();

            return vc;
        }

        public bool IsExpired()
        {
            if (ExpirationDate < DateTime.UtcNow.AddHours(SystemVariables.SysVars.TimeZone))
                return true;
            else
                return false;
        }
    }
}
